*use "Democratic Backsliding, conflict, and partisan mobilization_Replication.dta"

gen fatalitytotal= fatalitytsf+ fatalitypkk
gen lnfatality=ln(fatalitytotal+1)

label variable lnfatality "(Logged) total fatalities"

gen cumtoplamtutuklanma2017=toplamtutuklanma20152+toplamtutuklanma2017
gen cumtoplamtutuklanma2018=toplamtutuklanma20152+toplamtutuklanma2017+ toplamtutuklanma2018

label variable cumtoplamtutuklanma2017 "(Cum.) arrests 2017"
label variable cumtoplamtutuklanma2018 "(Cum.) arrests 2018"

*ttest pp. 12

ttest turnoutall if turnoutall~=. & ilcekodu~=. & ilcekodu~=99 , by(new_southeast_18)

*table 3
sum turnoutall hdpinc popsize illiteracy mcompetitiveness mbdpvote lnfatality toplamtutuklanma20152 cumtoplamtutuklanma2017 cumtoplamtutuklanma2018 makpvote mmhpvote mchpvote if illiteracy~=.  & hdpinc~=.


*table 4
regress turnoutall hdpinc popsize illiteracy mcompetitiveness mbdpvote lnfatality if electionid==20151 , robust
outreg2 using kayyumrv_4, bdec(3) word excel replace label
regress turnoutall hdpinc popsize illiteracy mcompetitiveness mbdpvote lnfatality toplamtutuklanma20152 if electionid==20152, robust
outreg2 using kayyumrv_4, bdec(3) word excel append label
regress turnoutall hdpinc popsize illiteracy mcompetitiveness mbdpvote lnfatality cumtoplamtutuklanma2017 if electionid==2017, robust
outreg2 using kayyumrv_4, bdec(3) word excel append label
regress turnoutall hdpinc popsize illiteracy mcompetitiveness mbdpvote lnfatality cumtoplamtutuklanma2018 if electionid==2018, robust
outreg2 using kayyumrv_4, bdec(3) word excel append label


*figure 3
regress turnoutall hdpinc popsize illiteracy mcompetitiveness mbdpvote lnfatality if electionid==20151 , robust
margins, over(hdpinc) atmeans
marginsplot, xtitle("Pro-Kurdish Party Municipality", size(2.5)) ytitle("Turnout", size(3))  title("June 2015", size(3))
graph save "Graph2A.gph", replace

regress turnoutall hdpinc popsize illiteracy mcompetitiveness mbdpvote lnfatality toplamtutuklanma20152 if electionid==20152, robust
margins, over(hdpinc) atmeans
marginsplot, xtitle("Pro-Kurdish Party Municipality", size(2.5)) ytitle("Turnout", size(3))  title("November 2015", size(3))
graph save "Graph2B.gph", replace

regress turnoutall hdpinc popsize illiteracy mcompetitiveness mbdpvote lnfatality cumtoplamtutuklanma2017 if electionid==2017, robust
margins, over(hdpinc) atmeans
marginsplot, xtitle("(Previously Pro-Kurdish Party Controlled) Trustee Municipality", size(2.5)) ytitle("Turnout", size(3))  title("2017", size(3))
graph save "Graph2C.gph", replace

regress turnoutall hdpinc popsize illiteracy mcompetitiveness mbdpvote lnfatality cumtoplamtutuklanma2018 if electionid==2018, robust
margins, over(hdpinc) atmeans
marginsplot, xtitle("(Previously Pro-Kurdish Party Controlled) Trustee Municipality", size(2.5)) ytitle("Turnout", size(3))  title("2018", size(3))
graph save "Graph2D.gph", replace


*cd "X"
graph combine Graph2A.gph Graph2B.gph Graph2C.gph Graph2D.gph, r(2) ycommon xcommon title("Turnout Rate")



*appendix 

*table a1 - alternative southeast codings

ttest turnoutall if turnoutall~=. & ilcekodu~=. & ilcekodu~=99 , by(new_southeast_24)
ttest turnoutall if turnoutall~=. & ilcekodu~=. & ilcekodu~=99 , by(new_southeast_16)

*table a3 - arrests between elections
regress turnoutall hdpinc popsize illiteracy mcompetitiveness mbdpvote lnfatality if electionid==20151 , robust
outreg2 using kayyumrv_a3, bdec(3) word excel replace label
regress turnoutall hdpinc popsize illiteracy mcompetitiveness mbdpvote lnfatality toplamtutuklanma20152 if electionid==20152, robust
outreg2 using kayyumrv_a3, bdec(3) word excel append label
regress turnoutall hdpinc popsize illiteracy mcompetitiveness mbdpvote lnfatality toplamtutuklanma2017 if electionid==2017, robust
outreg2 using kayyumrv_a3, bdec(3) word excel append label
regress turnoutall hdpinc popsize illiteracy mcompetitiveness mbdpvote lnfatality toplamtutuklanma2018 if electionid==2018, robust
outreg2 using kayyumrv_a3, bdec(3) word excel append label

*table a4 - pro-Kurdish incumbent as base category
regress turnoutall akpinc chpinc mhpinc other popsize illiteracy mcompetitiveness mbdpvote lnfatality makpvote if electionid==20151 , robust
outreg2 using kayyumrv_a4, bdec(3) word excel replace label
regress turnoutall akpinc chpinc mhpinc other popsize illiteracy mcompetitiveness mbdpvote lnfatality toplamtutuklanma20152 makpvote if electionid==20152, robust
outreg2 using kayyumrv_a4, bdec(3) word excel append label
regress turnoutall akpinc chpinc mhpinc other popsize illiteracy mcompetitiveness mbdpvote lnfatality cumtoplamtutuklanma2017 makpvote if electionid==2017, robust
outreg2 using kayyumrv_a4, bdec(3) word excel append label
regress turnoutall akpinc chpinc mhpinc other popsize illiteracy mcompetitiveness mbdpvote lnfatality cumtoplamtutuklanma2018 makpvote if electionid==2018, robust
outreg2 using kayyumrv_a4, bdec(3) word excel append label

*table a5 - controlling for akp vote
regress turnoutall hdpinc popsize illiteracy mcompetitiveness mbdpvote lnfatality makpvote if electionid==20151 , robust
outreg2 using kayyumrv_a5, bdec(3) word excel replace label
regress turnoutall hdpinc popsize illiteracy mcompetitiveness mbdpvote lnfatality toplamtutuklanma20152 makpvote if electionid==20152, robust
outreg2 using kayyumrv_a5, bdec(3) word excel append label
regress turnoutall hdpinc popsize illiteracy mcompetitiveness mbdpvote lnfatality cumtoplamtutuklanma2017 makpvote if electionid==2017, robust
outreg2 using kayyumrv_a5, bdec(3) word excel append label
regress turnoutall hdpinc popsize illiteracy mcompetitiveness mbdpvote lnfatality cumtoplamtutuklanma2018 makpvote if electionid==2018, robust
outreg2 using kayyumrv_a5, bdec(3) word excel append label

*table a6 - controlling for mhp vote
regress turnoutall hdpinc popsize illiteracy mcompetitiveness mbdpvote lnfatality mmhpvote if electionid==20151 , robust
outreg2 using kayyumrv_a6, bdec(3) word excel replace label
regress turnoutall hdpinc popsize illiteracy mcompetitiveness mbdpvote lnfatality toplamtutuklanma20152 mmhpvote if electionid==20152, robust
outreg2 using kayyumrv_a6, bdec(3) word excel append label
regress turnoutall hdpinc popsize illiteracy mcompetitiveness mbdpvote lnfatality cumtoplamtutuklanma2017 mmhpvote if electionid==2017, robust
outreg2 using kayyumrv_a6, bdec(3) word excel append label
regress turnoutall hdpinc popsize illiteracy mcompetitiveness mbdpvote lnfatality cumtoplamtutuklanma2018 mmhpvote if electionid==2018, robust
outreg2 using kayyumrv_a6, bdec(3) word excel append label

*table a7 - controlling for chp vote
regress turnoutall hdpinc popsize illiteracy mcompetitiveness mbdpvote lnfatality mchpvote if electionid==20151 , robust
outreg2 using kayyumrv_a7, bdec(3) word excel replace label
regress turnoutall hdpinc popsize illiteracy mcompetitiveness mbdpvote lnfatality toplamtutuklanma20152 mchpvote if electionid==20152, robust
outreg2 using kayyumrv_a7, bdec(3) word excel append label
regress turnoutall hdpinc popsize illiteracy mcompetitiveness mbdpvote lnfatality cumtoplamtutuklanma2017 mchpvote if electionid==2017, robust
outreg2 using kayyumrv_a7, bdec(3) word excel append label
regress turnoutall hdpinc popsize illiteracy mcompetitiveness mbdpvote lnfatality cumtoplamtutuklanma2018 mchpvote if electionid==2018, robust
outreg2 using kayyumrv_a7, bdec(3) word excel append label


